<template>
  <div>
    <div class="movie-box" @click="godetails(item)">
      <div class="movie-left">
        <img :src="item.poster" alt="" />
      </div>
      <div class="movie-content">
        <h4>
          {{ item.name }} <span class="movie-type">{{ item.item.name }}</span>
        </h4>
        <p>
          观众评分：<span class="movie-grade">{{ item.grade }}</span>
        </p>
        <p>主演：{{ item.actors.map((item) => item.name).join(" ") }}</p>
        <p>{{ item.nation }} | {{ item.runtime }}分钟</p>
      </div>
      <div class="movie-right">
        <van-button class="movie-buy" type="primary">购票</van-button>
      </div>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
const props = defineProps({
  item: Object,
});

const router = useRouter();

//路由跳转
function godetails(item) {
  router.push({
    path: "/moviedetails", //详情页面的路径
    query: {
      id: item.filmId,
    },
  });
}
</script>

<style lang="scss" scoped>
.movie-box {
  width: 100%;
  height: 125px;
  display: flex;
  padding: 10px 10px 10px 10px;
  border-bottom: 1px solid #ededed;
  p {
    color: #797d82;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
  }
  h4 {
    margin-bottom: 5px;
    font-size: 16px;
    color: #191a1b;
    font-weight: 500;
  }
  .movie-left {
    height: 100%;

    img {
      width: 75px;
      height: 100%;
    }
  }
  .movie-content {
    width: 55%;
    padding: 0 10px;
    display: flex;
    justify-content: center;
    flex-direction: column;
    .movie-type {
      color: white;
      background-color: #d3d6db;
      font-size: 12px;
      border-radius: 4px;
      padding: 0 4px;
    }
    .movie-grade {
      color: #ffb232;
    }
  }
  .movie-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    .movie-buy {
      width: 70px;
      text-align: center;
      background-color: #fff;
      border: 3px solid #ffddce;
      color: #ff5f16;
      border-radius: 5px;
      cursor: pointer;
    }
  }
}
</style>
